<!DOCTYPE html>
<html>
<head>
    <title>车位面积置换或正常购买</title>
    <#include "../common/common.ftl"/>
    <link rel="stylesheet" href="/style/contractForm.css" media="all">

</head>
<body>
<div class="layui-fluid">
    <form class="layui-form" id="carLotForm">
        <input type="hidden" name="contractId" value="${(contract.id)!}"/>
        <input type="hidden" name="carLotId" value="${(carLot.id)!}"/>
        <div class="layui-card">
            <div class="layui-card-header">车位面积置换或正常购买:</div>
            <div class="layui-card-body">
                <div class="layui-form-item">
                    <div class="layui-form-labelLong">
                        车位信息：&nbsp;&nbsp;&nbsp;【${(carLot.buildNum)!}】--【${(carLot.houseNum)!}】--【${(carLot.buildArea)!}】m²
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-labelLong">正常购买/面积换购：</label>
                    <div class="layui-input-blockRight">
                        <input type="radio"
                               <#if (!carLot.sfHg?? || carLot.sfHg == 1)>checked</#if>
                               name="sfHg" value="1" title="正常购买"/>
                        <input type="radio"
                               <#if (carLot.sfHg?? && carLot.sfHg == 2)>checked</#if>
                               name="sfHg" value="2" title="面积换购！"/>
                    </div>
                </div>
            </div>
        </div>

        <button style="display: none;" class="layui-btn" id="submitBtn" name="submitBtn" lay-submit=""
                lay-filter="submit">立即提交
        </button>
    </form>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['form', 'dataDict'], function () {
        var form = layui.form, $ = layui.jquery, parentIndex = parent.layer.getFrameIndex(window.name);

        //监听提交
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: 'carLotSave',
                type: 'post',
                data: $("#carLotForm").serialize(),//当前容器的全部表单字段，名值对形式：{name: value}
                async: false,
                success: function (data) {
                    if (data.code == "0001") {
                        parent.layer.close(parentIndex);
                        parent.parent.reloadSelectCarLotInfo();
                        parent.parent.loadSelectHouseInfo("${(contract.id)!}");
                    } else {
                        layer.msg(data.message, {anim: 6, icon: 2, time: 3000});
                    }
                }
            });
            return false;
            /*layer.open({
                title: false, shade: 0.5, content: "确定选择【"+data['buildNum']+"幢"+data['houseNum']+"】车位吗？", btn: ['确定', '取消'], closeBtn: 0, btnAlign: 'c'
                , yes: function (index) {
                    $.get("carLotSave", {contractId:"${(contract.id)!}",carLotId:data["id"],_time: new Date().getTime()}, function (data) {
                        if (data.code == "0001") {//成功
                            layer.msg(data.message, {anim: 0, icon: 1,time:1000},function(){
                                loadData();
                                parent.parent.reloadSelectCarLotInfo();
//                                    parent.layer.close(parentIndex);
                            });
                        } else {//失败
                            layer.msg(data.message, {anim: 6, icon: 2,time:3000});
                        }
                        layer.close(index);
                    });
                }
            });*/
        });
    });
</script>
</body>
</html>